<?php 
defined('_JEXEC') or die('Restricted access'); 

jimport( 'joomla.html.html.tabs' );
JHtml::_('jquery.framework');
JHtml::_('behavior.keepalive');
JHTML::_('behavior.tooltip'); 
JHtml::_('behavior.framework');
?>
<script type="text/javascript">
	//<![CDATA[
	Joomla.submitbutton = function(pressbutton){
		if (pressbutton == 'cancel') {
			submitform( pressbutton );
			return;
		}
		if (pressbutton == 'save') {
			if (document.adminForm.expire.value == "") {
				alert( 'Must have expired date !' );
				document.adminForm.expire.focus();
				return false;
			}
			submitform( pressbutton );
		}
	}
	
	function isNumberKey(evt,vip,tran,point)
	{
		if(evt.which == 45) return true;
		if(evt.which == 8) return true;
		if(vip.length > 8)return false;
		if((tran.length > 15) || (point.length > 10)){alert("You should not type number too big :)");return false;}
		var charCode = (evt.which) ? evt.which : event.keyCode
		if (charCode > 31 && (charCode < 48 || charCode > 57))
			return false;
		return true;
	}	
</script>

<form id="adminForm"  action="<?php echo JRoute::_("index.php?option=com_wrd&controller=exchange")?>" method="post" name="adminForm" >
	
	    	<?php 
	   			echo JHtml::_('bootstrap.startTabSet', 'exchange', array('active' => 'detail')); 
	   			echo JHtml::_('bootstrap.addTab', 'exchange', 'detail', 'Details');
	   		?>
	    	
			<table class="table table-striped adminlist">
				<tr>
					<td class="key">
						<label for="title"><?php echo JText::_('Vip Number')?>:</label>
					</td>
					<td colspan="2">
						<input readonly title="Type is number" onkeypress="return isNumberKey(event,this.value,true,true)" type="text"  maxlength="50" size="40" value="<?php echo empty($this->u_info->member_id) ? '' : $this->u_info->member_id ;?>" id="member_id" name="member_id" class="member_id"/>  
					</td>
				</tr>
				<tr>
					<td class="key">
						<label for="title"><?php echo JText::_('Point')?>:</label>
					</td>
					<td colspan="2">
						<input type="text" title="Type is number" onkeypress="return isNumberKey(event,true,true,this.value)" maxlength="50" size="40" value="<?php echo $this->data->point; ?>" id="point" name="point" class="point"/>  
					</td>
				</tr>
				<tr>
					<td class="key">
						<label for="title"><?php echo JText::_('Expired Date')?>:</label>
					</td>
					<td colspan="2">
						<?php
                            echo JHTML::_ ( 'calendar', ($this->data->expire != '0000-00-00' ? $this->data->expire : ''), 'expire', 'expire', '%Y-%m-%d');
                        ?>
					</td>
				</tr>
				<tr>
					<td class="key" valign="top">
						<label for="title"><?php echo JText::_('Description')?>:</label>
					</td>
					<td colspan="2">
						<textarea rows="10" cols="20" id="des" name="des" class="des"><?php echo $this->data->des; ?></textarea>
					</td>
				</tr>
            </table>

			
	<?php 
		echo JHtml::_('bootstrap.endTab');
		if(!empty($this->u_info)):
		echo JHtml::_('bootstrap.addTab', 'exchange', 'infotab', 'User Infomation');
	?>
	
					<table>
						<tr>
							<td><?php echo JText::_('Member ID') ;?></td>
							<td>:</td>
							<td><strong>
								<?php
									if(!empty($this->u_info->member_id)){
										echo $this->u_info->member_id;
									}
								?> 
								</strong>
							</td>
						</tr>
						<?php if(!empty($guest_name)):?>
						<tr>
							<td><?php echo JText::_('Name') ;?></td>
							<td>:</td>
							<td><strong>
								<?php
									if(!empty($this->u_info->f_name) || !empty($this->u_info->l_name)){
										$guest_name = $this->u_info->f_name." ".$this->u_info->l_name ;
									}else{
										$guest_name = '' ;
									}
									echo empty($guest_name)? '' : $this->u_info->prefix.' '.$guest_name ; 
								?>
								</strong>	
							</td>
						</tr>
						<?php endif; ?>
						<tr>
							<td><?php echo JText::_('Date of Birth') ;?></td>
							<td>:</td>
							<td>
								<?php
								  echo empty($this->u_info->dob)?'':date("d-m-Y",strtotime($this->u_info->dob)); 
								?> 
							</td>
						</tr>
						<tr>
							<td><?php echo JText::_('Mobile') ;?></td>
							<td>:</td>
							<td>
								<?php
									
									if(!empty($this->u_info->phone)){
										echo $this->u_info->phone;
									}
									else if(!empty($this->u_info->referer_phone)){
										echo $this->u_info->referer_phone;
									}
									else {
										echo "User have not mobiphone";
									}
								?>	
							</td>
						</tr>
						<?php if(!empty($this->job)): ?>
						<tr>
							<td><?php echo JText::_('Job Title') ;?></td>
							<td>:</td>
							<td>
								<?php  echo empty($this->job) ? '' : $this->job ; ?> 
							</td>
						</tr>
						<?php endif;?>
						<?php if(!empty($this->u_info->created_date)): ?>
						<tr>
							<td><?php echo JText::_('Member Joining Date') ;?></td>
							<td>:</td>
							<td>
								<?php
									echo empty($this->u_info->created_date) ? '':date('d-m-Y',strtotime($this->u_info->created_date)); 
								?> 
							</td>
						</tr>
						<?php endif;?>
						<?php if(!empty($this->outlet->name)): ?>
						<tr>
							<td><?php echo JText::_('Outlet') ;?></td>
							<td>:</td>
							<td>
								<?php
									echo empty($this->outlet->name) ? '' : $this->outlet->name ; 
								?> 
							</td>
						</tr>
						<?php endif; ?>
						<tr>
							<td><?php echo JText::_('Current points balance') ;?></td>
							<td>:</td>
							<td>
								<?php
									echo number_format($this->p_o_u->point,0,'.',','); 
								?> 
							</td>
						</tr>
						<tr>
							<td><?php echo JText::_('Total spending') ;?></td>
							<td>:</td>
							<td>
								<?php
									echo number_format($this->u_info->total_spend,0,'.',','); 
								?> 
							</td>
						</tr>
					</table>
				<?php 
				echo JHtml::_('bootstrap.endTab');
		?>
	
	<?php endif ; ?>
	<input type="hidden" name="controller" value="exchange" />
	<input type="hidden" name="option" value="com_wrd" />
	<input type="hidden" name="vip_num" value="<?php echo $this->u_info->member_id ;?>" />
	<input type="hidden" name="forward" value="<?php echo $this->forward ; ?>" />
	<input type="hidden" name="id" value="<?php echo (int)$this->data->id; ?>" />
	<input type="hidden" name="created_id" value="<?php echo (int)$this->data->user_id; ?>" />
	<input type="hidden" name="profile_id" value="<?php echo $this->u_info->id; ?>" />
	<input type="hidden" name="modify_id" value="<?php echo (int)$this->user->id; ?>" />
	<input type="hidden" name="task" value="" />
	<?php echo JHtml::_('bootstrap.endTabSet'); echo JHTML::_( 'form.token' ); ?>
</form>